Motf WaitForDistance
Wait for the web to travel a distance (in user units) to reach or exceed a specific value. The distance is measured from the point where the last MOTF.ResetTracking() is executed, or MOTF.WaitForDistance() command is executed provided that the optional flag isAbsolute is set false. If the argument isAbsolute is false, the MOTF counters are automatically reset to zero.
Syntax
| WaitForDistance( float distance ) |
| WaitForDistance( float distance, bool isAbsolute ) |
Parameters
| distance | float | Distance of web travel since the last MOTF.ResetTracking() or MOTF.WaitForDistance() |
| isAbsolute | bool | Determines the measurement starting conditions. |
| isAbsolute = TRUE | absolute - indicates that the wait is to use scaled encoder counts from the last MOTF.ResetTracking(). The MOTF counters continue count a measure distance. |
| isAbsolute = FALSE | relative - indicates that the wait is to use scaled encoder counts from the last MOTF.ResetTracking() or MOTF.WaitForDistance() where isAbsolute is FALSE. The MOTF counters automatically reset when the distance is met or exceeded. |
Copy
Example
-- This sample marks a series of circles spaced at a constant distance
SetUnits(Units.Millimeters)
-- Use MOTF Port 0
MOTF.Mode = Encoder.ExternalSingleAxis
-- Web direction
MOTF.Direction = Direction.BottomToTop
-- 10um linear resolution for example
encoderLinResInMmPerCount = 0.010
-- Bits/Mm * Mm/Count -> Bits/Count
MOTF.CalFactor = System.CalFactorY *
encoderLinResInMmPerCount
-- Initialize the MOTF settings
MOTF.Initialize()
-- Initialize laser/scan-head settings
Laser.MarkSpeed = 1000
Laser.MarkDelay = 200
Laser.JumpSpeed = 3000
Laser.JumpDelay = 200
Laser.Frequency = 20
Laser.DutyCycle1 = 50
Laser.Power = 50
Laser.LaserOnDelay = 75
Laser.LaserOffDelay = 125
Laser.PolyDelay = 50
Laser.VariPolyDelayFlag = true
-- Wait for this web travel before marking
partDistance = 50.
-- Wait for start signal
IO.WaitForIo(Pin.Din.UserIn1,Trigger.Edge.Rising, 0, 0, true)
-- Initialize to wait the initial distance
MOTF.ResetTracking()
System.Flush()
-- Repeat until aborted via external signal
while IO.ReadPin(Pin.Din.UserIn4) == false do
MOTF.WaitForDistance(partDistance)
-- Counters are automatically reset when WaitForDistance() releases
MOTF.StartTracking(Tracking.WhileMarking)
Image.Circle(0, 0, 20)
MOTF.StopTrackingAndJump(0, 0, 0, 200)
Laser.WaitForEnd()
-- Counters are still counting and distance being measured
end
Report ("Job Finished")